// 1.引入http模块
const http = require('http');

// 2.创建服务对象
const server = http.createServer((req, res) => {

  // 实例化URL的对象
  let url = new URL('http://www.xxx.com/search?a=100&b=200');
  console.log(url);

  // 输出路径
  console.log(url.pathname);

  // 输出查询字符串
  console.log(url.searchParams.get('a'));

  res.end('hello HTTP');
});

// 3.监听端口，启动服务
server.listen(9000, () => {
  // 服务启动成功后的回调
  console.log('服务器启动成功');
});